package com.campus.mapper;

import com.campus.annotation.AutoFill;
import com.campus.enumeration.OperationType;
import com.campus.pojo.dto.ShopPageQueryDTO;
import com.campus.pojo.entity.Shop;
import com.campus.pojo.vo.ShopVO;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ShopMapper {
    Page<ShopVO> pageQuery(ShopPageQueryDTO shopPageQueryDTO);

    @Select("select * from shop where id = #{id}")
    Shop getShopById(Long id);

    @Insert("insert into shop (name, address, phone, image, rating, cuisine_type) values (#{name}, #{address}, #{phone}, #{image}, #{rating}, #{cuisineType})")
    @AutoFill(value = OperationType.INSERT)
    @Options(useGeneratedKeys = true, keyColumn = "id", keyProperty = "id")
    void insert(Shop shop);

    void update(Shop shop);

    void deleteByIds(List<Long> ids);
}
